import { menuList } from '@/request/api'

//封装一个接口类型
interface StateMenu {
    menulist: Array<object>
}
const state = {
    menulist: []
}

const getters = {
    getMenu(state: StateMenu) {
        return state.menulist
    }
}

const mutations = {
    REQ_MENUlIST(state: StateMenu, payload: any) {
        state.menulist = payload
    }
}

const actions = {
    getMenuListAction(context: any) {
        menuList(
            { istree: 1 }
        ).then((res) => {
            if (res.code == 200) {
                context.commit('REQ_MENUlIST', res.list)
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}